package com.gas.project.gas.grade.service.impl;

import java.util.List;

import com.gas.common.utils.DateUtils;
import com.gas.common.utils.text.Convert;
import com.gas.project.gas.grade.domain.CourseValidGrade;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.gas.project.gas.grade.mapper.CourseGradeMapper;
import com.gas.project.gas.grade.domain.CourseGrade;
import com.gas.project.gas.grade.service.ICourseGradeService;
import org.springframework.transaction.annotation.Transactional;

/**
 * 课程成绩Service业务层处理
 *
 * @author xyl
 * @date 2022-04-03
 */
@Service
public class CourseGradeServiceImpl implements ICourseGradeService {
    @Autowired
    private CourseGradeMapper courseGradeMapper;

    /**
     * 查询课程成绩
     *
     * @param courseGradeId 课程成绩ID
     * @return 课程成绩
     */
    @Override
    public CourseGrade selectCourseGradeById(Long courseGradeId) {
        return courseGradeMapper.selectCourseGradeById(courseGradeId);
    }

    /**
     * 查询课程成绩列表
     *
     * @param courseGrade 课程成绩
     * @return 课程成绩
     */
    @Override
    public List<CourseGrade> selectCourseGradeList(CourseGrade courseGrade) {
        return courseGradeMapper.selectCourseGradeList(courseGrade);
    }

    /**
     * 新增课程成绩
     *
     * @param courseGrade 课程成绩
     * @return 结果
     */
    @Override
    public int insertCourseGrade(CourseGrade courseGrade) {
        courseGrade.setCreateTime(DateUtils.getNowDate());
        return courseGradeMapper.insertCourseGrade(courseGrade);
    }

    /**
     * 修改课程成绩
     *
     * @param courseGrade 课程成绩
     * @return 结果
     */
    @Override
    public int updateCourseGrade(CourseGrade courseGrade) {
        courseGrade.setUpdateTime(DateUtils.getNowDate());
        return courseGradeMapper.updateCourseGrade(courseGrade);
    }

    /**
     * 删除课程成绩对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteCourseGradeByIds(String ids) {
        return courseGradeMapper.deleteCourseGradeByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除课程成绩信息
     *
     * @param courseGradeId 课程成绩ID
     * @return 结果
     */
    @Override
    public int deleteCourseGradeById(Long courseGradeId) {
        return courseGradeMapper.deleteCourseGradeById(courseGradeId);
    }

    @Transactional
    @Override
    public String importTeacher(List<CourseGrade> courseGradeList) {
        for (CourseGrade courseGrade : courseGradeList) {
            courseGradeMapper.insertCourseGrade(courseGrade);
        }
        return "导入成功！";
    }

    @Override
    public List<CourseValidGrade> selectValidGradeList(CourseValidGrade courseGrade) {
        return courseGradeMapper.selectValidGradeList(courseGrade);
    }

    @Override
    public CourseValidGrade selectValidGradeCollect(CourseValidGrade courseGrade) {
        return courseGradeMapper.selectValidGradeCollect(courseGrade);
    }
}
